<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<label>密码：</label>
		<input type="password" />
		<button type="button">btn</button>
	</body>
	<script type="text/javascript">
		var psdFlag = true;
		var input = document.querySelector("input");
		var btn = document.querySelector("button");
		btn.onclick = function() {
			if (psdFlag) {
				input.type = "text";
				psdFlag = false;
			} else {
				input.type = "password";
				psdFlag = true;
			}
		}
	</script>
</html>
